package priv.mill.xml;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import freemarker.template.Configuration;
import freemarker.template.Template;

public class FreeMarkerTest {

	private static final Logger logger = Logger.getLogger(FreeMarkerTest.class);
	public static void main(String[] args) throws Exception {	
//		Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
//		configuration.setDefaultEncoding("utf-8");
//		File file = new File("d:/temp");
//		configuration.setDirectoryForTemplateLoading(file);
		ApplicationContext context = new FileSystemXmlApplicationContext("classpath:ioc-test.xml");
		Configuration configuration = (Configuration) context.getBean("freeConfig");
		Template template = configuration.getTemplate("2.txt");
		Map<String, Object> dataModel=new HashMap<String, Object>();
		dataModel.put("name", "李四");
		
		template.process(dataModel, new OutputStreamWriter(System.out));
	}
	
}
